package sevensoft.结构型模式.组合模式;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;

import java.io.File;
import java.util.*;

public class FileDir extends FileComponent{

    List<FileComponent> fileComponentList=new ArrayList<>();

    public FileDir(String name, int level) {
        super(name, level);
    }


    @Override
    public FileComponent add(FileComponent fileComponent) {
        fileComponentList.add(fileComponent);
        return this;
    }

    @Override
    public FileComponent remove(FileComponent fileComponent) {
        fileComponent.remove(fileComponent);
        return this;
    }

    @Override
    public FileComponent getChild(int level) {
        return null;
    }

    @Override
    public void out() {
        for ( int i = 0; i < level; i++ ) {
            System.out.print("——");
        }
        System.out.println(name);
        fileComponentList.forEach(FileComponent::out);
    }
}
